package com.yckj.day06;

/**
 * TODO 类的封装
 *
 * @author shengyuee
 * @version 1.0
 * 2025/7/23 16:14
 */
public class User {
    private String username;
    private String password;

    public User() {
    }

    public User(String username, String password) {
        this(); // this只能放在第一行
        // 1、this表示当前对象的引用，方法被哪个对象调用，this就代表哪个对象
        this.username = username;
        this.password = password;

    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        // 3、访问当前对象的属性和方法，可以使用this.属性，this.方法去调用。
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "User{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
